const mongoose = require('mongoose');

const accountSchema = new mongoose.Schema({
    deviceName: { type: String, required: true, unique: true },
    accountNickName: { type: String, required: true },
    accountId: { type: String, required: true, unique: true },
    orderAmount: { type: Number, required: false, default: 0 },
    orderNum: { type: Number, required: false, default: 0 },
    commerceAmount: { type: Number, required: false, default: 0 },
    commerceNum: { type: Number, required: false, default: 0 },
    predictTotalAmount: { type: Number, required: false, default: 0 },
    predictcommerceAmount: { type: Number, required: false, default: 0 },
    accountType: { type: String, required: false },
    accountRemarks: { type: String, required: false },
    accountStatus: { type: String, default: "正常" }
});

const publishDeviceSchema = new mongoose.Schema({
    deviceName: { type: String, required: true, unique: true },
    accounts: [accountSchema]  // 设备下的多个账号
});

module.exports = mongoose.model('PublishDevice', publishDeviceSchema);
